/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoo.gamecenter.sdk.login.plugin.login.view;

import android.content.Context;
import android.os.Handler;
import android.text.Html;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import com.qihoo.gamecenter.sdk.login.plugin.d;
import com.qihoo.gamecenter.sdk.login.plugin.d.a;
import com.qihoo.gamecenter.sdk.login.plugin.f.a;
import com.qihoo.gamecenter.sdk.login.plugin.h.c;
import com.qihoo.gamecenter.sdk.login.plugin.h.e;
import com.qihoo.gamecenter.sdk.login.plugin.h.f;

public class g {
    private static g a = null;
    private Context b;
    private WindowManager c;
    private WindowManager.LayoutParams d;
    private View e = null;
    private Handler f = new Handler();
    private TextView g;
    private a h;
    private String i;
    private Runnable j = new Runnable() {
        public void run() {
            if (!(g.a(g.this).isShown()))
                return;
            g.b(g.this);
        }
    };

    public static g a(Context paramContext, String paramString) {
        if (a == null)
            synchronized (g.class) {
                if (a == null)
                    a = new g(paramContext, paramString);
            }
        return a;
    }

    private g(Context paramContext, String paramString) {
        this.b = paramContext;
        this.c = ((WindowManager) this.b.getApplicationContext().getSystemService("window"));
        this.d = new WindowManager.LayoutParams(-2, -2, 2003, 40, -2);
        this.d.gravity = 49;
        this.d.y = f.a(this.b, 20.0F);
        this.h = a.a(this.b);
        this.i = paramString;
    }

    public void a(String paramString1, String paramString2) {
        if (TextUtils.isEmpty(paramString1))
            return;
        b();
        if (this.e == null)
            this.e = a();
        int k = paramString1.length();
        if (k > 15)
            paramString1 = paramString1.substring(0, 15) + "...";
        String str = "<font color='#666666'>" + paramString2 + "</font>&nbsp;<font color='#ff7f16'>" + paramString1
                + "</font>";
        this.g.setText(Html.fromHtml(str));
        this.g.setGravity(16);
        this.c.addView(this.e, this.d);
        this.f.postDelayed(this.j, 3000L);
    }

    private View a() {
        LinearLayout localLinearLayout1 = new LinearLayout(this.b);
        localLinearLayout1.setOrientation(0);
        localLinearLayout1.setGravity(17);
        localLinearLayout1.setBackgroundDrawable(this.h.a(-1073741812));
        LinearLayout localLinearLayout2 = new LinearLayout(this.b);
        localLinearLayout2.setOrientation(1);
        localLinearLayout2.setGravity(1);
        localLinearLayout2.setLayoutParams(new LinearLayout.LayoutParams(f.a(this.b, 300.0F), -2));
        localLinearLayout1.addView(localLinearLayout2);
        localLinearLayout2.setOnClickListener(new View.OnClickListener() {
            public void onClick(View paramView) {
                e.a("WellcomeToGame", new Object[] { "floatingView clicked!!!" });
            }
        });
        LinearLayout.LayoutParams localLayoutParams1 = new LinearLayout.LayoutParams(-2, -2);
        localLayoutParams1.topMargin = f.a(this.b, 13.0F);
        localLayoutParams1.bottomMargin = f.a(this.b, 13.0F);
        this.g = new TextView(this.b);
        this.g.setLayoutParams(localLayoutParams1);
        this.g.setTextSize(1, c.j);
        this.g.setGravity(17);
        this.g.setSingleLine(true);
        localLinearLayout2.addView(this.g);
        LinearLayout localLinearLayout3 = new LinearLayout(this.b);
        LinearLayout.LayoutParams localLayoutParams2 = new LinearLayout.LayoutParams(-2, -2);
        localLayoutParams2.bottomMargin = f.a(this.b, 13.0F);
        localLinearLayout3.setLayoutParams(localLayoutParams2);
        localLinearLayout3.setGravity(17);
        ImageView localImageView = new ImageView(this.b);
        LinearLayout.LayoutParams localLayoutParams3 = new LinearLayout.LayoutParams(f.a(this.b, 25.0F), f.a(this.b,
                25.0F));
        localLayoutParams3.rightMargin = f.a(this.b, 8.0F);
        localImageView.setLayoutParams(localLayoutParams3);
        a.a(this.b).a(localImageView, 1073741874);
        localLinearLayout3.addView(localImageView);
        TextView localTextView = new TextView(this.b);
        localTextView.setLayoutParams(new LinearLayout.LayoutParams(-2, -2));
        localTextView.setTextColor(-11776948);
        localTextView.setTextSize(1, c.j);
        localTextView.setText(d.a(d.a.bI));
        localLinearLayout3.addView(localTextView);
        localLinearLayout2.addView(localLinearLayout3);
        return localLinearLayout1;
    }

    private synchronized void b() {
        if (this.e == null)
            return;
        this.c.removeView(this.e);
        this.f.removeCallbacks(this.j);
        this.e = null;
    }
}